package com.sikulifang.bank.simulation.util;

import java.io.UnsupportedEncodingException;

public class TTTT {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String reqEncoding = "GBK";
        byte[] context;
        String sendBody = "<ap>  \n" +
                "<head>    \n" +
                "<tr_code>310101</tr_code>    \n" +
                "<corp_no>0020005695</corp_no>    \n" +
                "<user_no>00003</user_no>    \n" +
                "<serial_no>0</serial_no>    \n" +
                "<req_no>20240822153325153</req_no>    \n" +
                "<tr_acdt>20240822</tr_acdt>    \n" +
                "<tr_time>153325</tr_time>    \n" +
                "<atom_tr_count>1</atom_tr_count>    \n" +
                "<channel>0</channel>    \n" +
                "<sign />    \n" +
                "<filename />    \n" +
                "<ogl_serial_no>1</ogl_serial_no>   \n" +
                " <reserved />  \n" +
                " </head>  \n" +
                " <body>    \n" +
                " <acno>310069037013007477307</acno>    \n" +
                " <cur_code>CNY</cur_code>    \n" +
                " <bank_no></bank_no>    \n" +
                " <query_date>20240822</query_date>  \n" +
                " </body>\n" +
                " </ap>\n";

        byte[] tem = sendBody.getBytes(reqEncoding);
        String len = String.valueOf(tem.length).trim();
        len = "0" + len;
        len = String.format("%1$-7s", len);
        String conteee = len + sendBody;
        System.out.println(conteee);


        byte[] messageByte = sendBody.getBytes("GBK");
        // 7位头
        String length = "0" + messageByte.length + "       ";
        length = length.substring(0, 7);
        conteee = length + sendBody;
        System.out.println(conteee);

    }
}
